package com.ruicar.afs.cloud.manage.common.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruicar.afs.cloud.common.core.query.QueryCondition;
import com.ruicar.afs.cloud.common.core.security.util.SecurityUtils;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import com.ruicar.afs.cloud.manage.common.condition.ManageUpcomeTasksRecordCondition;
import com.ruicar.afs.cloud.manage.common.entity.ManageUpcomeTasksRecord;
import com.ruicar.afs.cloud.manage.common.service.ManageUpcomeTasksRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: xudongdong
 * @date: 2020/07/21
 * @description: 待办任务一览
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/findUpcomeTasks")
public class UpcomeTasksController {

    private ManageUpcomeTasksRecordService manageUpcomeTasksRecordService;

    @PostMapping(value = "/findUpcomeTasksList")
    @ApiOperation(value = "待办任务一览")
    public IResponse<List<ManageUpcomeTasksRecord>> findUpcomeTasksList(@RequestBody QueryCondition<ManageUpcomeTasksRecordCondition> condition) {
        condition.getCondition().setProcessPerson(SecurityUtils.getUser().getUsername());
        Page page = new Page(condition.getPageNumber(), condition.getPageSize());
        IPage<List<ManageUpcomeTasksRecord>> list = manageUpcomeTasksRecordService.findUpcomeTasksList(page, condition.getCondition());
        return IResponse.success(list);
    }
}
